package com.ztgf.shopping.api.client.epg;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.epg.EpgAggregationBannerBO;
import com.ztgf.shopping.models.dto.epg.EpgAggregationBannerDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;
import com.ztgf.shopping.models.service.epg.IEpgAggregationCategoryService;
import com.ztgf.shopping.models.bo.epg.EpgAggregationCategoryBO;
import com.ztgf.shopping.models.dto.epg.EpgAggregationCategoryDTO;

import java.util.List;

/**
 * 聚合页分类控制器
 *
 * @author YUE
 * @Date 2020-06-04 15:38:08
 */

@RestController
@RequestMapping("/api/epgAggregationCategory")
@Slf4j
@Api(value = "EpgAggregationCategoryApiController",tags = "聚合页分类Api接口")
public class EpgAggregationCategoryApiController {

    @DubboReference
    private IEpgAggregationCategoryService epgAggregationCategoryService;

    /**
     * 频道栏目列表 根据功能id
     * @param moduleId 功能id
     * @return
     */
    @ApiOperation(value = "频道栏目列表 根据功能id",notes = "频道栏目列表 根据功能id")
    @PostMapping("/getListByModuleId")
    public Result<List<EpgAggregationCategoryDTO>> getListByModuleId(Long moduleId){
        EpgAggregationCategoryBO epgAggregationCategoryBO = new EpgAggregationCategoryBO();
        epgAggregationCategoryBO.setModuleId(moduleId);
        List<EpgAggregationCategoryDTO> epgAggregationBannerDTOList = epgAggregationCategoryService.getBySelectCategoryInfoNoPage(epgAggregationCategoryBO);
        return new Result<>(epgAggregationBannerDTOList);
    }

    @PostMapping("/get")
    @ApiOperation(value = "根据id查找",notes = "根据id查找")
    @ApiImplicitParam(name = "id",value = "id",required = true,paramType = "query", dataType = "Long")
    public Result<EpgAggregationCategoryDTO> get(@RequestParam("id") Long id){
        if(id == null){
            return new Result<>(CodeEnum.FAIL_100002 );
        }

        EpgAggregationCategoryDTO dto = epgAggregationCategoryService.selectById(id);

        return new Result<>(dto);
    }

    @ApiOperation(value = "聚合页分类列表",notes = "聚合页分类列表")
    @PostMapping("/queryList")
    public Result<List<EpgAggregationCategoryDTO>> queryList(EpgAggregationCategoryBO bo){
        List<EpgAggregationCategoryDTO> epgAggregationCategoryDTOList = epgAggregationCategoryService.getBySelectCategoryInfoNoPage(bo);
        return new Result<>(epgAggregationCategoryDTOList);
    }
}
